package it.learn.kafka.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.web.reactive.WebFluxRegistrations;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.reactive.result.method.RequestMappingInfo;
import org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping;

import java.util.Map;

@Slf4j
@Component
public class WebFluxRegistrationsImpl implements WebFluxRegistrations {

    @Override
    public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
        return new RequestMappingHandlerMapping0();
    }

    static class RequestMappingHandlerMapping0 extends RequestMappingHandlerMapping {

        @Override
        protected void handlerMethodsInitialized(Map<RequestMappingInfo, HandlerMethod> handlerMethods) {
            if (handlerMethods.isEmpty()) {
                logger.warn("未获取到Controller的RequestMapping 信息...");
            }
            for (Map.Entry<RequestMappingInfo, HandlerMethod> method : handlerMethods.entrySet()) {
                RequestMappingInfo mappingInfo = method.getKey();
                HandlerMethod handler = method.getValue();

                String name = mappingInfo.getName();
                String description = handler.toString();

                System.out.println("===============================");
            }

        }
    }

}
